package Threads.GeekBang_test.ThreadLocal_test;

public class test2 {
    private String content;

    private String getContent(){
        return content;
    }

    private void setConent(String content){
        this.content=content;
    }

    public static void main(String[] args) {
        test2 test2=new test2();
        for (int i=0;i<5;i++){
            new Thread(()->{
                //使用syn关键字解决，但是效率太低了
                synchronized (test2.class) {
                    test2.setConent(Thread.currentThread().getName() + "data");
                    System.out.println("--------");
                    System.out.println(Thread.currentThread().getName() + test2.getContent());
                }
            },"t"+i).start();
        }
    }
}
